﻿using AutoCreateMapAndRoad.MapFolder.VisitorFolder;
using Microsoft.Xna.Framework;
using System;

namespace AutoCreateMapAndRoad.MapFolder.Elements
{
    public class KhoiL : DoanDuong
    {
        int docao1, docao2;
        string huong;
        Random rand;

        public KhoiL()
        {
            rand = new Random();
            docao1 = rand.Next(4, 5);
            docao2 = rand.Next(4, 5);
            CreateHuong();
        }
        public void CreateHuong()
        {
            if (Map.huong.Equals("phai"))
            {
                int temp = rand.Next(3000) % 4;
                if (temp == 0) huong = "trenphai";
                if (temp == 2) huong = "traitren";
                if (temp == 3) huong = "traiduoi";
                if (temp == 1) huong = "duoiphai";
            }
            else if (Map.huong.Equals("tren"))
            {
                int temp = rand.Next(3000) % 3;
                if (temp == 0) huong = "traitren";
                if (temp == 1) huong = "traiduoi";
                if (temp == 2) huong = "duoiphai";
            }
            else if (Map.huong.Equals("duoi"))
            {
                int temp = rand.Next(3000) % 3;
                if (temp == 0) huong = "trenphai";
                if (temp == 2) huong = "traitren";
                if (temp == 1) huong = "traiduoi";
            }
            else
            {
                int temp = rand.Next(3000) % 4;
                if (temp == 0) huong = "trenphai";
                if (temp == 1) huong = "trentrai";
                if (temp == 2) huong = "duoiphai";
                if (temp == 3) huong = "duoitrai";
            }

            if (Map.curPosi.Y == 0)
            {
                int temp = rand.Next(3000) % 2;
                if (temp == 0) huong = "traitren";
                if (temp == 1) huong = "traiduoi";
            }
            else if (Map.curPosi.X == 0)
            {
                if (Map.huong.Equals("phai")) huong = "trenphai";
                else huong = "traiduoi";
            }
            else if (Map.curPosi.X == Map.SizeOfMatrix.X - 1)
            {
                if (Map.huong.Equals("phai")) huong = "duoiphai";
                else huong = "traitren";
            }
        }
        public void accept(Visitor visitor)
        {
            visitor.visit(this);
        }
        public string getHuong()
        {
            return huong;
        }
        public int getDocao1()
        {
            return docao1;
        }
        public int getDocao2()
        {
            return docao2;
        }
    }
}
